<template>
  <transition name="modal">
      <div class="modal-mask" @click="$emit('close')">
          <div class="modal-container" @click="preventClick($event)">

              <div class="modal-header">
                <slot name="header">
                  <h3>您需要订阅课程才可以收听全部音频内容</h3>
                </slot>
              </div>

              <div class="modal-body">
                <slot name="body">
                  <h3>
                    付费后您可享用
                  </h3>
                  <ul>
                    <li>该课程的所有音频</li>
                    <li>松鼠听听不定期赠送的限时优惠课程</li>
                    <li>加入微信群与其他用户共同学习进步</li>
                  </ul>
                </slot>
              </div>

              <div class="modal-footer">
                <slot name="footer">
                  <button class="modal-default-button left" @click="$emit('close')" style="outline: none">
                    我再看看
                  </button>
                  <button class="modal-default-button right" @click="$emit('buyCourse')" style="outline: none">
                    现在购买
                  </button>
                </slot>
              </div>

          </div>
      </div>
  </transition>
</template>


<script>

export default {
  name: 'sq-buy-confirm-box',
  data () {
    return {
    }
  },
  methods: {
    preventClick(event) {
      if(event.target.tagName === 'A' || event.target.tagName === 'a' || event.target.nodeName === 'A' || event.target.nodeName === 'a') {
        return true;
      }
      event.preventDefault();
      event.stopPropagation();
    }
  }
}
</script>

<style scoped>

.modal-mask {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100vh;
  background-color: rgba(0, 0, 0, .5);
  transition: opacity .3s ease;
  display: flex;
  align-content: center;
  justify-content: center;
}

.modal-container {
  width: 100vw;
  width: 100%;
  max-width: 400px;
  margin: auto 12px;
  background-color: #fff;
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
  transition: all .3s ease;
  font-family: Helvetica, Arial, sans-serif;
  height: 280px;
  position: relative;
}

.modal-header h3 {
  margin-top: 0;
  color: #000;
  height: 22px;
  line-height: 22px;
  font-size: 16px;
  margin-top: 28px;
  margin-bottom: 28px;
  font-weight: normal;
  padding-left: 30px;
  padding-right: 30px;
}

.modal-body {
  margin: 20px 0 20px 0;
}

.modal-body h3 {
  margin: 0px;
}

.modal-body ul {
  text-align: left;
  color: #999999;
  font-size: 14px;
}

.modal-body li {
  line-height: 24px;
}

.sq-input-group {
  display: flex;
  align-items: center;
  padding-left: 28px;
  padding-right: 28px;
}

.sq-input-group label {
  flex-basis: 70px;
  flex-shrink: 0;
}

.sq-input-group input {
  flex-grow: 1;
  height: 48px;
  border: 1px solid #ccc;
  padding-left: 12px;
  flex: 1;
  font-size: 14px;
}

#sq-input-mobile {
  margin-bottom: 12px;
}

#sq-input-code {
  width: 60%;
  flex-grow: 1;
  min-width: 120px;
  max-width: 180px;
}

.sq-input-group button {
  width: 50%;
  min-width: 100px;
  background-color: #fff;
  font-size: 14px;
  color:#3385ff;
  padding: 0px;
  border: 0px;
  outline: none;
  flex-grow: 1;
  flex-basis: 100px;
}

.errtips {
  margin-top: 10px;
  font-size: 14px;
  height: 24px;
  padding-left: 12px;
  color: #ff4a3d;
  align-self: flex-start;
}

.usertips {
  margin-top: 0;
  font-size: 14px;
  height: 14px;
  color: #999999;
  align-self: flex-end;
}

.usertips a {
  text-decoration: none;
  color:#3385ff;
}
.modal-footer {
  height: 44px;
  display: flex;
}

.modal-footer button{
  height: 100%;
  border: 0px;
  flex-grow: 1;
  color: #fff;
  background-color: #fe6b40;
  font-size: 16px;
  border-radius: 2px;
}

.modal-footer .left{
  margin-left: 28px;
  color: #666666;
  background-color: #ffffff;
  border: 1px solid #666666;
}

.modal-footer .right{
  margin-left: 28px;
  margin-right: 28px;
  color: #fff;
  background-color: #fe6b40;
}

.modal-default-button {
  float: right;
}

.modal-enter {
  opacity: 0;
}

.modal-leave-active {
  opacity: 0;
}

.modal-enter .modal-container,
.modal-leave-active .modal-container {
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
}

</style>
